#pragma once
#include "json_trans.h"


json_struct(PositionJ,
	mapping(float, x);
mapping(float, y);
mapping(float, z);
mapping(float, a);
mapping(float, b);
mapping(float, c);
prop(&x, &y, &z, &a, &b, &c);
)

struct Position {
	float x;
	float y;
	float z;
	float a;	// z轴旋转
	float b;	// y
	float c;	// x
	void TransFromPositonJ(const PositionJ& in)
	{
		x = in.x();
		y = in.y();
		z = in.z();
		a = in.a();
		b = in.b();
		c = in.c();
	}
	PositionJ TransToPositonJ()
	{
		PositionJ out = {};
		out.x = x;
		out.y = y;
		out.z = z;
		out.a = a;
		out.b = b;
		out.c = c;
		return out;
	}
};


struct PositionQuaternion {
	float x;
	float y;
	float z;
	float Q1;
	float Q2;	// y
	float Q3;	// x
	float Q4;	// x
};

json_struct(SizeJ,
	mapping(int, length);
mapping(int, width);
mapping(int, height);
prop(&length, &width, &height);
);

struct Size {
	int length;
	int width;
	int height;
	void TransFromSizeJ(const SizeJ& in)
	{
		width = in.width();
		length = in.length();
		height = in.height();
	}
	SizeJ TransToSizeJ()
	{
		SizeJ out = {};
		out.height = height;
		out.length = length;
		out.width = width;
		return out;
	}
};


// 物料信息
json_struct(SkuInfoJ,
	mapping(bool, valied);
mapping(QString, skuNo);
mapping(int, type);
mapping(SizeJ, size);
mapping(double, weight);
mapping(int, pos);
prop(&valied, &skuNo, &type, &size, &weight, &pos);
)

struct SkuInfo {
	bool valied;	// 物料信息是否有效
	QString skuNo;	// 物料编号
	int type;	// 物料类型，0：纸箱 1：料箱
	Size size;
	float weight;
	int pos;	// 物料的摆放方式：0：表示自定义，由算法决定，1-n表示垛形编号或者来料方式（1：横向物料长垂直于输送的长， 2：纵向）
	void clear()
	{
		valied = false;
		skuNo.clear();
		size = {};
		weight = 0.0f;
	}
	void TransfromSkuInfoJ(const SkuInfoJ& in)
	{
		valied = in.valied();
		skuNo = in.skuNo();
		type = in.type();
		size.TransFromSizeJ(in.size());
		weight = in.weight();
		pos = in.pos();
	}
	SkuInfoJ TransToSkuInfoJ()
	{
		SkuInfoJ out = {};
		out.valied = valied;
		out.pos = pos;
		out.size = size.TransToSizeJ();
		out.weight = weight;
		out.type = type;
		return out;
	}
};

